{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "# 为MNIST数据集构建一个分类器，并在测试集上达成超过90%的精度 。提示：KNeighborsClassiﬁer对这个任务非常有效"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 导入数据集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.datasets import fetch_mldata # 读取数据集内容,\t读取本地\n",
    "mnist = fetch_mldata('mnist-original', data_home='./') # 标签和训练数据\n",
    "X, y = mnist['data'], mnist['target'] # 建立测试集\n",
    "X_train,X_test,y_train,y_test=X[:60000,:],X[60000:,:],y[:60000],y[60000:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 0, 0, ..., 0, 0, 0],\n",
       "       [0, 0, 0, ..., 0, 0, 0],\n",
       "       [0, 0, 0, ..., 0, 0, 0],\n",
       "       ...,\n",
       "       [0, 0, 0, ..., 0, 0, 0],\n",
       "       [0, 0, 0, ..., 0, 0, 0],\n",
       "       [0, 0, 0, ..., 0, 0, 0]], dtype=uint8)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X_train"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 划分训练集和测试集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np \n",
    "import sklearn\n",
    "import matplotlib.pyplot as plt \n",
    "import pandas as pd\n",
    "# 训练集洗牌赋值\n",
    "shuffle_index=np.random.permutation(60000) \n",
    "X_train,y_train=X_train[shuffle_index],y[shuffle_index]  \n",
    "# 测试集洗牌赋值\n",
    "shuffle_index=np.random.permutation(10000)\n",
    "X_test,y_test=X_test[shuffle_index],y_test[shuffle_index]\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 选择标签"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy86wFpkAAAACXBIWXMAAAsTAAALEwEAmpwYAAAOUElEQVR4nO3db4xUZZbH8d9ZYCQKibg0LQpuD6MvlkhkSAVX3aArkahvdKKzGV6MmOgyGkxmFBMJazLG+HfjQDCuGGYhMDorYmYUNMYdg0TCCyeWyCIscWWRZXpsoVCEHv+hePZFXzctdj3VXffWn+7z/SSVqrrn3ronl/5xq+qpqsfcXQBGvr9qdQMAmoOwA0EQdiAIwg4EQdiBIEY3c2cTJ070rq6uZu4SCGX//v06fPiwDVTLFXYzu1LSCkmjJP2buz+UWr+rq0vlcjnPLgEklEqlqrW6n8ab2ShJ/yrpKknTJc03s+n1Ph6Axsrzmn22pL3uvs/dj0taL+maYtoCULQ8YT9b0p/63e/Oln2LmS00s7KZlSuVSo7dAcgjT9gHehPgO5+9dfdV7l5y91JHR0eO3QHII0/YuyVN7Xd/iqT387UDoFHyhP0NSeeZ2ffN7HuSfiJpUzFtASha3UNv7v6Vmd0m6T/UN/S2xt13F9YZgELlGmd395ckvVRQLwAaiI/LAkEQdiAIwg4EQdiBIAg7EARhB4Ig7EAQhB0IgrADQRB2IAjCDgRB2IEgCDsQBGEHgiDsQBCEHQiCsANBEHYgCMIOBEHYgSAIOxAEYQeCIOxAEIQdCIKwA0EQdiAIwg4EQdiBIAg7EESuWVyBkWratGnJ+nvvvZesb968OVm//PLLh9xTXrnCbmb7JfVKOiHpK3cvFdEUgOIVcWb/B3c/XMDjAGggXrMDQeQNu0v6g5m9aWYLB1rBzBaaWdnMypVKJefuANQrb9gvcfdZkq6StMjM5py8gruvc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CDgTR6rCvavH+U9q1t3btS6K3ejWlt5a+ZgfQPK0+swNoEsIOBNGSsJvZlWb2jpntNbMlreihGjPbb2Zvm9kOMyu3uJc1ZnbIzHb1W3aGmb1iZu9m1wPOsdei3u4xsz9nx26HmV3dot6mmtkWM9tjZrvN7OfZ8pYeu0RfTTluTX/NbmajJP23pCskdUt6Q9J8d/+vpjZShZntl1Ry95Z/AMPM5kj6i6TfuPv52bJ/kfSRuz+U/Uc5wd3vapPe7pH0l1ZP453NVjS5/zTjkq6VdKNaeOwSff2jmnDcWnFmny1pr7vvc/fjktZLuqYFfbQ9d98q6aOTFl8jaV12e536/liarkpvbcHde9x9e3a7V9I304y39Ngl+mqKVoT9bEl/6ne/W+0137tL+oOZvWlmC1vdzAA63b1H6vvjkTSpxf2crOY03s100jTjbXPs6pn+PK9WhH2gqaTaafzvEnefJekqSYuyp6sYnEFN490sA0wz3hbqnf48r1aEvVvS1H73p0h6vwV9DMjd38+uD0l6Tu03FfXBb2bQza4Ptbif/9dO03gPNM242uDYtXL681aE/Q1J55nZ983se5J+ImlTC/r4DjM7LXvjRGZ2mqR5ar+pqDdJWpDdXiBpYwt7+ZZ2mca72jTjavGxa/n05+7e9Iukq9X3jvz/SPrnVvRQpa9pkv4zu+xudW+Snlbf07ov1feM6CZJfy1ps6R3s+sz2qi3JyW9LWmn+oI1uUW9/b36XhrulLQju1zd6mOX6Kspx42PywJB8Ak6IAjCDgRB2IEgCDsQBGEHgiDsQBCEHQji/wB7QkTxqKYf0wAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "some_digit=X_train[23456] \n",
    "some_digit_img=some_digit.reshape(28,28) \n",
    "import matplotlib\n",
    "%matplotlib inline \n",
    "plt.imshow(some_digit_img,cmap=matplotlib.cm.binary) \n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 选择模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([False])"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.neighbors import KNeighborsClassifier \n",
    "# 多标签分类 拿出为6的标签\n",
    "y_train_6=(y_train==6) \n",
    "# 算出距离\n",
    "kn_clf = KNeighborsClassifier() \n",
    "kn_clf.fit(X_train,y_train_6) \n",
    "some_digit=X_train[23456] \n",
    "some_digit=[some_digit]\n",
    "# 测试指定数据\n",
    "kn_clf.predict(some_digit)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0, 221, 255,  66,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,  17,  26,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0, 111, 242,  75,   8,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  20, 205, 197,\n",
       "         4,   0,   0,   0,   0,   0,   0,   0,   8, 189, 254,  93,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  48,\n",
       "       254,  75,   0,   0,   0,   0,   0,   0,   0,   0,  19, 254, 232,\n",
       "        24,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0, 152, 243,  34,   0,   0,   0,   0,   0,   0,   0,   9, 132,\n",
       "       254, 166,   3,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,  41, 244, 228,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "        37, 236, 247,  43,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,  39, 229, 254,  75,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0, 173, 247,  78,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0, 125, 254, 254,  89,   0,   0,   0,   0,\n",
       "         0,   0,   3, 113, 253, 221,  28,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0, 114, 245, 254, 254, 251, 119,  23,\n",
       "         0,   0,   0,  15, 107, 254, 254, 106,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,  60, 212, 254, 254, 254, 254,\n",
       "       254, 239, 188,  84,   0, 132, 254, 254, 254, 210,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0, 136, 254, 254, 254,\n",
       "       242, 242, 254, 254, 254, 255, 231, 209, 254, 254, 225,  53,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 150, 254,\n",
       "       254, 242,  36,  23,  95, 213, 248, 254, 254, 254, 254, 200,  29,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "       120, 251, 244, 102,   0,   0,   0,   0,  48,  63, 219, 254, 246,\n",
       "        50,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,  63,   0,   0,   0,   0,   0,   0,   0, 188, 254,\n",
       "       254,  87,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  62,\n",
       "       249, 254, 148,   4,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         5, 184, 254, 193,   5,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,  68, 240, 254,  63,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,  19, 209, 254, 141,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,  17, 229, 254, 208,  10,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,  12, 226, 232,  59,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n",
       "         0,   0,   0,   0], dtype=uint8)"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X_train[23456] "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 精度和召回"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Fitting 5 folds for each of 6 candidates, totalling 30 fits\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "c:\\users\\wang-289\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\sklearn\\externals\\joblib\\numpy_pickle.py:93: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.\n",
      "  pickler.file_handle.write(chunk.tostring('C'))\n",
      "c:\\users\\wang-289\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\sklearn\\externals\\joblib\\numpy_pickle.py:93: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.\n",
      "  pickler.file_handle.write(chunk.tostring('C'))\n",
      "c:\\users\\wang-289\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\sklearn\\externals\\joblib\\numpy_pickle.py:93: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.\n",
      "  pickler.file_handle.write(chunk.tostring('C'))\n"
     ]
    }
   ],
   "source": [
    "# 网格搜索\n",
    "from sklearn.model_selection import GridSearchCV\n",
    "param_grid = [{'weights': [\"uniform\", \"distance\"], 'n_neighbors': [3, 4, 5]}]\n",
    "knn_clf = KNeighborsClassifier()\n",
    "grid_search = GridSearchCV(knn_clf, param_grid, cv=5, verbose=3, n_jobs=-1) \n",
    "grid_search.fit(X_train, y_train)\n",
    "grid_search.best_params_ \n",
    "grid_search.best_score_\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 测试集验证\n",
    "from sklearn.metrics import accuracy_score \n",
    "y_pred = grid_search.predict(X_test) \n",
    "accuracy_score(y_test, y_pred)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
